package top.laoshuzi.cloudplatform;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import java.io.IOException;

import top.laoshuzi.cloudplatform.network.NetworkService;
import top.laoshuzi.cloudplatform.servo.ServoHandler;
import top.laoshuzi.media.CloudPlatformMediaUtils;


/**
 * Skeleton of an Android Things activity.
 * <p>
 * Android Things peripheral APIs are accessible through the class
 * PeripheralManagerService. For example, the snippet below will open a GPIO pin and
 * set it to HIGH:
 * <p>
 * <pre>{@code
 * PeripheralManagerService networkService = new PeripheralManagerService();
 * mLedGpio = networkService.openGpio("BCM6");
 * mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
 * mLedGpio.setValue(true);
 * }</pre>
 * <p>
 * For more complex peripherals, look for an existing user-space driver, or implement one if none
 * is available.
 *
 * @see <a href="https://github.com/androidthings/contrib-drivers#readme">https://github.com/androidthings/contrib-drivers#readme</a>
 */

public class MainActivity extends Activity {

    //    AttitudeHanlder attitudeHanlder;
    NetworkService networkService;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        findViewById(R.id.register).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//            }
//        });
//        findViewById(R.id.unregister).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//            }
//        });
//        findViewById(R.id.display).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//            }
//        });

//        attitudeHanlder = AttitudeHanlder.getInstance();
//
//        try {
//            attitudeHanlder.initialize(this);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

        networkService = NetworkService.getInstance();
        networkService.start(12345);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        networkService.stop();


//        try {
//            attitudeHanlder.close();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }


}
